Fix ICE and type mismatch with array type aliases and const generics#7638
Fix ICE and type mismatch with array type aliases and const generics#7638Dnreikronos wants to merge 5 commits into
Conversation
extract_type_parameters ignored array lengths when matching concrete arrays against generic impls like [T; N], so N was never mapped to its literal value. Additionally, MaterializeConstGenerics did not recurse through TypeInfo::Alias, stopping materialization at the alias boundary. Closes FuelLabs#7616
Covers struct fields typed as array aliases, nested aliases, equality via the Eq trait, and Vec<Alias>::get().unwrap() return type resolution.
|
Thanks for the contribution! Before we can merge this, we need @Dnreikronos to sign the Fuel Labs Contributor License Agreement. |
PR SummaryMedium Risk Overview
Adds e2e Reviewed by Cursor Bugbot for commit 33126b7. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
@ironcev this is ready. |
Description
Closes #7616
Using a type alias for an array (
type ArrayU8Len2 = [u8; 2]) as a struct field and then comparing two such structs with==triggered an ICE: "Const generic not materialized". TheEqimpl for arrays is generic over the lengthN, so resolving it needs the alias to carry its concrete length down into the const generic machinery. Two spots dropped it on the way.extract_type_parametersnow pulls the length out of array types the same way it already does for structs and enums: when the original side carries an ambiguous length variable (N) and the concrete side has a literal,Ngets bound to that literal.MaterializeConstGenerics for TypeIdalso handlesTypeInfo::Aliasnow, recursing into the aliased type instead of stopping at the alias, which mirrors the existingRefhandling.The new e2e test exercises array aliases and nested aliases (
[ArrayU8Len2; 3]) as struct fields, equality comparison to hit theEqconst generic path, andVec<Alias>::get().unwrap()return-type resolution. Existingtype_alias*,const_generic*, andarray*suites still pass.Checklist
Breaking*orNew Featurelabels where relevant.